<template>
	<view class="content">
		<heade title="所属类别" cross bg_color="bg_fff">
		</heade>
		<view class="" class=" box_box bg_fff p-b10" style="border-top: 2rpx solid #e8e8e8;width: 100%;z-index: 9;overflow-y: auto;">
			<view class="f-s14">
				<view class="" >	
					<view v-for="(item,i) in kehuList">
						<view class="p-l20 p-t10 p-b10 bg_f6f6f6" @click="kehuClick(i,item)">{{item.Name}}</view>
						<view class="" v-for="(item2,j) in item.sub">
							<view class="p-l30 p-t10 p-b10 p-t10 p-b10 bg_fafafa"  @click="stairClick(i,j,item2)" v-if="item.stair">{{item2.Name}}</view>
							<view class="p-l40 p-t10 p-b10 p-t10 p-b10 bg_fafafa" @tap="subset(item3)" v-if="item2.headset" v-for="item3 in item2.sub">{{item3.Name}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				kehuList:[]
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				this.$http.get('valet_order/partner_class').then(res => {
					if(res.code == 1) {
						res.data.forEach((e,i) => {
							e.stair = false
							res.data[i].sub.forEach(j => {
								j.headset = false
							})
						})
						this.kehuList = res.data
						// this.list = res.data
					}
				})
			},
			kehuClick(i,item) {
				this.kehuList[i].stair = !this.kehuList[i].stair
				this.kehuList[i].sub.forEach(e => {
					if(item.Name == e.Name) {
						this.kehuList[i].stair = !this.kehuList[i].stair
					}else {
						e.headset = false
					}
				})
				
			},
			stairClick(i,j,item) {
				this.kehuList[i].sub.forEach(e => {
					if(item.Name == e.Name) {
						this.kehuList[i].sub[j].headset = !this.kehuList[i].sub[j].headset
					}else {
						e.headset = false
					}
				})
			},
			subset(item) {
				var pages = getCurrentPages();
				var pages1 = pages[pages.length - 2]
				pages1.$vm.category = item
				uni.navigateBack()
			},
		}
	}
</script>

<style lang="scss">
	
</style>